//
//  HZL_LikeTableViewCell.m
//  B_Project
//
//  Created by 胡佳俊 on 15/12/4.
//  Copyright © 2015年 HZL. All rights reserved.
//

#import "HZL_LikeTableViewCell.h"

@interface HZL_LikeTableViewCell ()
@property (nonatomic, retain) UIImageView *img;
@property (nonatomic, retain) UILabel *desc;
@property (nonatomic, retain) UILabel *name;
//@property (nonatomic, retain) UILabel *distance;
@property (nonatomic, retain) UIView *blackView;

@end
@implementation HZL_LikeTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.img = [[UIImageView alloc] init];
        self.img.contentMode = UIViewContentModeScaleAspectFill;
        self.img.clipsToBounds = YES;
        [self.contentView addSubview:self.img];
        
        self.blackView = [[UIImageView alloc] init];
        self.blackView.backgroundColor = [UIColor blackColor];
        self.blackView.alpha = 0.2;
        [self.img addSubview:self.blackView];
        
        if (self.findModel) {
            self.desc = [[UILabel alloc] init];
            self.desc.textColor = [UIColor whiteColor];
            //        self.desc.backgroundColor = [UIColor blueColor];
            self.desc.textAlignment = NSTextAlignmentCenter;
            self.desc.font = [UIFont boldSystemFontOfSize:15];
            [self.contentView addSubview:self.desc];
        }
        
        self.name = [[UILabel alloc] init];
        self.name.textColor = [UIColor whiteColor];
        //        self.name.backgroundColor = [UIColor redColor];
        self.name.textAlignment = NSTextAlignmentCenter;
        self.name.font = [UIFont boldSystemFontOfSize:17];
        [self.contentView addSubview:self.name];
        

        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.img.frame = CGRectMake(10, 10, self.contentView.frame.size.width - 20, self.contentView.frame.size.height - 10);
    //    [self.img mas_makeConstraints:^(MASConstraintMaker *make) {
    //        make.center.mas_equalTo(self.contentView);
    //        make.size.mas_equalTo(self.contentView.frame.size);
    //    }];
    self.blackView.frame = self.contentView.frame;
    
//    self.desc.frame = CGRectMake(0, self.img.frame.size.height * 0.55 -10, self.contentView.frame.size.width , 30);
    
    self.name.frame = CGRectMake(0, self.img.frame.size.height * 0.5, self.contentView.frame.size.width, 25);

}

- (void)setModel:(HZL_StoreModel *)model
{
    if (_model != model) {
        _model = model;
    }
    self.name.text = model.title;
    [self.img sd_setImageWithURL:[NSURL URLWithString:model.img] placeholderImage:nil];
}
- (void)setFindModel:(HZL_FindModel *)findModel
{
    if (_findModel != findModel) {
        _findModel = findModel;
    }
    self.name.text = findModel.name;
    self.desc.text = findModel.desc;
    
    [self.img sd_setImageWithURL:[NSURL URLWithString:findModel.img]];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
